package com.yj.cloud.auth.service;

import com.yj.cloud.auth.domain.LoginVo;
import com.yj.cloud.common.core.exception.ServiceException;
import com.yj.cloud.common.core.util.SpringUtils;
import com.yj.cloud.system.api.domain.vo.RemoteClientVo;

/**
 * 认证策略接口
 */

public interface IAuthStrategy {
    String BASE_NAME = "AuthStrategy";


    /**
     * 登录认证
     */
    static LoginVo login(String body, RemoteClientVo client, String grantType) {
        String beanName = grantType + BASE_NAME;
        if (!SpringUtils.containsBean(beanName)) {
            throw new ServiceException("授权类型不正确!");
        }
        IAuthStrategy instance = SpringUtils.getBean(beanName);
        return instance.login(body, client);
    }

    LoginVo login(String body,  RemoteClientVo client);

}
